package opera;

import book.BookList;

import java.util.Scanner;

public class ReturnOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        Scanner scanner=new Scanner(System.in);
        System.out.print("请输入需要归还图书名：");
        String name=scanner.nextLine();

        int currentSize=bookList.getUsedSize();
        for (int i = 0; i < currentSize; i++) {
            if(name.equals(bookList.getBooks(i).getName())) {
                bookList.getBooks(i).setBorrowed(false);
                System.out.println("归还成功！");
                return;
            }
        }
        System.out.println("未找到该书，归还失败！");
    }
}
